/**
 * 话题推荐模块
 */
define( [
	'jquery',
	'../../modules/createEditor',
	'../../lib/editData'
], function( $, editorObj, editData ) {
	editorObj.ready( function() {
		if ( editData.isCreate ) {
			sessionStorage.removeItem( 'topic_recommend' );
			var $tr = $( '.article-title-input .topic_recommend' ).on( {
					mouseenter: function() {
						clearTimeout( fadeOutId );
					},
					mouseleave: function() {
						fadeOutId = fadeOutTimeout();
					}
				} ),
				fadeOutId;

			function fadeOutTimeout() {
				return setTimeout( function() {
					$( this ).fadeOut();
				}.bind( $tr ), 5e3 );
			}
			setTimeout( function() {
				if ( !sessionStorage.getItem( 'topic_recommend' ) ) {
					$tr.fadeIn( 1e3 ).on( 'click', function() {
						$( this ).fadeOut();
						clearTimeout( fadeOutId );
					} );
				}
				fadeOutId = fadeOutTimeout();
			}, 10e3 );
		}
	} );
} );